package com.example.banneractivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.youth.banner.Banner;
import com.youth.banner.loader.ImageLoader;

import java.io.LineNumberInputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * 使用Banner进行轮播
 */

public class MainActivity extends AppCompatActivity {
    private Banner banner;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        banner=findViewById(R.id.banner01);
        initBanner();

    }
    private List<Integer> images=new ArrayList<>();

    public void initBanner(){
        images.add(R.mipmap.qingtian);
        images.add(R.mipmap.fuchen);
        images.add(R.mipmap.yintian);
        images.add(R.mipmap.dayuzhuanqing);
        banner.setImages(images);
        banner.setImageLoader(new my());
        banner.start();
    }
    private class  my extends ImageLoader{
        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            Glide.with(context).load(path).into(imageView);
        }
    }

}

















